#pragma once

#include <xy/geom/camera.h>
#include <xy/render/mesh.h>
#include <xy/render/shader.h>

namespace xy
{

namespace render
{

class context
{
  protected:
    std::shared_ptr<painter> m_painter;        // 画家
    std::shared_ptr<geom::camera> m_camera;    // 相机视角
    std::map<std::string, image_t> m_textures; // 纹理缓存

  public:
    enum Texture
    {
        Yellow2d,
        White2d,
        Red2d,
        Green2d,
        Blue2d,
        Black2d,
        Chess
    };

    /**
     * @brief 构造函数
     *
     * @param width
     * @param height
     * @param msaaLevel
     */
    context(int width, int height, int msaaLevel);

    virtual void draw() = 0;
    auto painter() const -> decltype(m_painter);
    auto camera() const -> decltype(m_camera);

    /**
     * @brief 获得纹理
     *
     * @param name
     * @return image_t
     */
    image_t texture(std::string name) const;

    /**
     * @brief 从文件加载纹理
     *
     * @param filename
     */
    void create_texture(std::string filename);

    /**
     * @brief 从预定义纹理创建纹理
     *
     * @param texture
     */
    void create_texture(Texture texture);
};

} // namespace render

} // namespace xy
